
<template>
    <div class="Business">
        <div class="table">
            <Table border :columns="tableHead" :data="tableData"></Table>
            <Row class="table-foot">
                <Col span="4">
                    <Checkbox v-model="all">显示全部</Checkbox>
                </Col>
                <!-- TODO 总计 -->
                <Col span="20">总计: 费用总计、费用金额、豁免额、到期金额</Col>
            </Row>
        </div>

        <Form ref="formData" :model="formData" :rules="formRules" :label-width="120">
            <Row>
                <Col :xs="8">
                    <FormItem label="减免比例%">
                        <Input clearable v-model="formData.newBankAccount" placeholder :disabled="isApprove" />
                    </FormItem>
                </Col>
                <Col :xs="8">
                    <FormItem label="豁免额" class="item-disabled">
                        <Input clearable v-model="formData.exemptionAmt" :disabled="isApprove" />
                    </FormItem>
                </Col>
            </Row>
            <Row>
                <Col>
                    <Button type="primary">详情</Button>
                </Col>
            </Row>
        </Form>
    </div>
</template>
<script>
    import {findBankCardDetail, findOldBankInfo} from "_p/basic/api/contract/post-loan-info-change";

    export default {
    props: {
        dataDict: {
            type: Object,
            required: true
        },
        isApprove: {
            type: Boolean,
            require: true
        },
        //对象参数包含：合同号码、角色类型
        Obj: {
            type: Object,
            required: true
        },
        pageParams: {
            type: Object,
            required: true
        }
    },
    data() {
        return {
            showForm: {
                type: "",
                phone: false,
                address: false
            },
            all: '',
            oldData: {},
            formData: {
                custName: "",
                oldHomeAddress: "",
                oldPhone: "",
                oldWorkAddress: "",
                oldWorkPhone: "",
                newHomeAddress: "",
                newPhone: "",
                newWorkAddress: "",
                newWorkPhone: ""
            },
            formRules: {
                type: [
                    { required: true, message: "请选择一项", trigger: "change" }
                ],
                changeSubject: [
                    { required: true, message: "请选择一项", trigger: "change" }
                ]
            },
            tableHead: [
                {
                    title: '案件编号',
                    key: 'name'
                },
                {
                    title: '费用类型',
                    key: 'name'
                },
                {
                    title: '申请编号',
                    key: 'name'
                },
                {
                    title: '内部合同号',
                    key: 'name'
                },
                {
                    title: '客户姓名',
                    key: 'name'
                },
                {
                    title: '到期日',
                    key: 'name'
                },
                {
                    title: '费用总计',
                    key: 'name'
                },
                {
                    title: '费用金额',
                    key: 'name'
                },
                {
                    title: '累计豁免金额',
                    key: 'name'
                },
                {
                    title: '核销额',
                    key: 'name'
                },
                {
                    title: '到期金额',
                    key: 'name'
                },
                {
                    title: '处理状态',
                    key: 'name'
                },
                {
                    title: '申请日期',
                    key: 'name'
                },
                {
                    title: '结束日期',
                    key: 'name'
                },
                {
                    title: '生效',
                    key: 'name'
                },
                {
                    title: '生效日',
                    key: 'name'
                },
            ],
            tableData: []
        };
    },
    computed: {},
    watch: {},
    created() { },
    mounted() {
        this.init();
    },
    methods: {
        init() {
            if (this.pageParams)
                this.getBasicInfo(this.pageParams.contractNo);
            // this.formData = Object.assign({}, this.formData, this.pageParams);
        },

        getBasicInfo(data) {
            if (!data) return;

            findOldBankInfo(data).then(res => {
                if (res.code === "0000") {
                    console.log("old info", res.data);
                    this.oldData = Object.assign({}, this.oldData, res.data);
                }
            });
            findBankCardDetail(data).then(res => {
                if (res.code === "0000") {
                    console.log("new info", res.data);
                    this.formData = Object.assign({}, this.formData, res.data);
                }
            });
        },

        /*
         * formData 数据验证 验证通过后 将数据传回父级处理  (保存/提交/审核 通用)
         * @param {String} funcName 回传给父级的方法 (注意父级需要传方法)
         * @param {Object} [data]   父级带来的数据
         */
        formValidate(funcName, data) {
            if (!funcName) return;

            this.$refs.formData.validate(valid => {
                if (valid) {
                    let d = Object.assign({}, data, this.oldData, this.formData, this.Obj);

                    this.$emit(funcName, d);
                } else {
                    this.$Message.error("验证不通过!");
                    this.$emit("closeSpin");
                    verifyErrorToView(this.$refs.formData.fields);
                }
            });
        },
    }
};
</script>
<style scoped>
.item-disabled {
    margin-bottom: 0;
}
.type-box {
    display: flex;
    flex-flow: row;
}
.item-title {
    text-align: center;
}
.table-foot {
    padding-top: 8px;
    padding-bottom: 16px;
}
</style>
